using HKB.Common;
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Diagnostics;
namespace HKB.Data.Dal.H_TransferFieldTableAdapters
{
	[GeneratedCode("System.Data.Design.TypedDataSetGenerator", "2.0.0.0"), DataObject(true), HelpKeyword("vs.data.TableAdapter"), Designer("Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), DesignerCategory("code"), ToolboxItem(true)]
	public class HL_TransferFieldTableAdapter : Component
	{
		private SqlDataAdapter _adapter;
		private SqlConnection _connection;
		private SqlCommand[] _commandCollection;
		private bool _clearBeforeFill;
		[System.Diagnostics.DebuggerNonUserCode]
		private SqlDataAdapter Adapter
		{
			get
			{
				if (this._adapter == null)
				{
					this.InitAdapter();
				}
				return this._adapter;
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		internal SqlConnection Connection
		{
			get
			{
				if (this._connection == null)
				{
					this.InitConnection();
				}
				return this._connection;
			}
			set
			{
				this._connection = value;
				if (this.Adapter.InsertCommand != null)
				{
					this.Adapter.InsertCommand.Connection = value;
				}
				if (this.Adapter.DeleteCommand != null)
				{
					this.Adapter.DeleteCommand.Connection = value;
				}
				if (this.Adapter.UpdateCommand != null)
				{
					this.Adapter.UpdateCommand.Connection = value;
				}
				for (int i = 0; i < this.CommandCollection.Length; i++)
				{
					if (this.CommandCollection[i] != null)
					{
						this.CommandCollection[i].Connection = value;
					}
				}
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		protected SqlCommand[] CommandCollection
		{
			get
			{
				if (this._commandCollection == null)
				{
					this.InitCommandCollection();
				}
				return this._commandCollection;
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		public bool ClearBeforeFill
		{
			get
			{
				return this._clearBeforeFill;
			}
			set
			{
				this._clearBeforeFill = value;
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		public HL_TransferFieldTableAdapter()
		{
			this.ClearBeforeFill = true;
		}
		[System.Diagnostics.DebuggerNonUserCode]
		private void InitAdapter()
		{
			this._adapter = new SqlDataAdapter();
			DataTableMapping dataTableMapping = new DataTableMapping();
			dataTableMapping.SourceTable = "Table";
			dataTableMapping.DataSetTable = "HL_TransferField";
			dataTableMapping.ColumnMappings.Add("TransferFieldID", "TransferFieldID");
			dataTableMapping.ColumnMappings.Add("TransferID", "TransferID");
			dataTableMapping.ColumnMappings.Add("FieldName", "FieldName");
			dataTableMapping.ColumnMappings.Add("HLFieldName", "HLFieldName");
			dataTableMapping.ColumnMappings.Add("DefaultValue", "DefaultValue");
			this._adapter.TableMappings.Add(dataTableMapping);
			this._adapter.DeleteCommand = new SqlCommand();
			this._adapter.DeleteCommand.Connection = this.Connection;
			this._adapter.DeleteCommand.CommandText = "DELETE FROM [HL_TransferField] WHERE (([TransferFieldID] = @Original_TransferFieldID))";
			this._adapter.DeleteCommand.CommandType = CommandType.Text;
			this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@Original_TransferFieldID", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "TransferFieldID", DataRowVersion.Original, false, null, "", "", ""));
			this._adapter.InsertCommand = new SqlCommand();
			this._adapter.InsertCommand.Connection = this.Connection;
			this._adapter.InsertCommand.CommandText = "INSERT INTO [HL_TransferField] ([TransferID], [FieldName], [HLFieldName], [DefaultValue]) VALUES (@TransferID, @FieldName, @HLFieldName, @DefaultValue)";
			this._adapter.InsertCommand.CommandType = CommandType.Text;
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@TransferID", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "TransferID", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@FieldName", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "FieldName", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@HLFieldName", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "HLFieldName", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@DefaultValue", SqlDbType.Text, 0, ParameterDirection.Input, 0, 0, "DefaultValue", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand = new SqlCommand();
			this._adapter.UpdateCommand.Connection = this.Connection;
			this._adapter.UpdateCommand.CommandText = "UPDATE [HL_TransferField] SET [TransferID] = @TransferID, [FieldName] = @FieldName, [HLFieldName] = @HLFieldName, [DefaultValue] = @DefaultValue WHERE (([TransferFieldID] = @Original_TransferFieldID))";
			this._adapter.UpdateCommand.CommandType = CommandType.Text;
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@TransferID", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "TransferID", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@FieldName", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "FieldName", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@HLFieldName", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "HLFieldName", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@DefaultValue", SqlDbType.Text, 0, ParameterDirection.Input, 0, 0, "DefaultValue", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Original_TransferFieldID", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "TransferFieldID", DataRowVersion.Original, false, null, "", "", ""));
		}
		[System.Diagnostics.DebuggerNonUserCode]
		private void InitConnection()
		{
			this._connection = new SqlConnection();
			this._connection.ConnectionString = Conn.CurrenConnectionStrings;
		}
		[System.Diagnostics.DebuggerNonUserCode]
		private void InitCommandCollection()
		{
			this._commandCollection = new SqlCommand[4];
			this._commandCollection[0] = new SqlCommand();
			this._commandCollection[0].Connection = this.Connection;
			this._commandCollection[0].CommandText = "SELECT TransferFieldID, TransferID, FieldName, HLFieldName, DefaultValue\r\nFROM HL_TransferField";
			this._commandCollection[0].CommandType = CommandType.Text;
			this._commandCollection[1] = new SqlCommand();
			this._commandCollection[1].Connection = this.Connection;
			this._commandCollection[1].CommandText = "INSERT INTO [HL_TransferField] ([TransferID], [FieldName], [HLFieldName], [DefaultValue]) VALUES (@TransferID, @FieldName, @HLFieldName, @DefaultValue)";
			this._commandCollection[1].CommandType = CommandType.Text;
			this._commandCollection[1].Parameters.Add(new SqlParameter("@TransferID", SqlDbType.VarChar, 50, ParameterDirection.Input, 0, 0, "TransferID", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[1].Parameters.Add(new SqlParameter("@FieldName", SqlDbType.VarChar, 50, ParameterDirection.Input, 0, 0, "FieldName", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[1].Parameters.Add(new SqlParameter("@HLFieldName", SqlDbType.VarChar, 50, ParameterDirection.Input, 0, 0, "HLFieldName", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[1].Parameters.Add(new SqlParameter("@DefaultValue", SqlDbType.Text, 2147483647, ParameterDirection.Input, 0, 0, "DefaultValue", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[2] = new SqlCommand();
			this._commandCollection[2].Connection = this.Connection;
			this._commandCollection[2].CommandText = "DELETE FROM [HL_TransferField] WHERE (([TransferFieldID] = @TransferFieldID))";
			this._commandCollection[2].CommandType = CommandType.Text;
			this._commandCollection[2].Parameters.Add(new SqlParameter("@TransferFieldID", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "TransferFieldID", DataRowVersion.Original, false, null, "", "", ""));
			this._commandCollection[3] = new SqlCommand();
			this._commandCollection[3].Connection = this.Connection;
			this._commandCollection[3].CommandText = "SELECT TransferFieldID, TransferID, FieldName, HLFieldName, DefaultValue\r\nFROM HL_TransferField\r\nWHERE TransferID=@TransferID";
			this._commandCollection[3].CommandType = CommandType.Text;
			this._commandCollection[3].Parameters.Add(new SqlParameter("@TransferID", SqlDbType.VarChar, 50, ParameterDirection.Input, 0, 0, "TransferID", DataRowVersion.Current, false, null, "", "", ""));
		}
		[DataObjectMethod(DataObjectMethodType.Select, true), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual H_TransferField.HL_TransferFieldDataTable GetAllTransferField()
		{
			this.Adapter.SelectCommand = this.CommandCollection[0];
			H_TransferField.HL_TransferFieldDataTable hL_TransferFieldDataTable = new H_TransferField.HL_TransferFieldDataTable();
			this.Adapter.Fill(hL_TransferFieldDataTable);
			return hL_TransferFieldDataTable;
		}
		[DataObjectMethod(DataObjectMethodType.Select, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual H_TransferField.HL_TransferFieldDataTable GetTransferFieldByTransferID(string TransferID)
		{
			this.Adapter.SelectCommand = this.CommandCollection[3];
			if (TransferID == null)
			{
				this.Adapter.SelectCommand.Parameters[0].Value = System.DBNull.Value;
			}
			else
			{
				this.Adapter.SelectCommand.Parameters[0].Value = TransferID;
			}
			H_TransferField.HL_TransferFieldDataTable hL_TransferFieldDataTable = new H_TransferField.HL_TransferFieldDataTable();
			this.Adapter.Fill(hL_TransferFieldDataTable);
			return hL_TransferFieldDataTable;
		}
		[HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int Update(H_TransferField.HL_TransferFieldDataTable dataTable)
		{
			return this.Adapter.Update(dataTable);
		}
		[HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int Update(H_TransferField dataSet)
		{
			return this.Adapter.Update(dataSet, "HL_TransferField");
		}
		[HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int Update(DataRow dataRow)
		{
			return this.Adapter.Update(new DataRow[]
			{
				dataRow
			});
		}
		[HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int Update(DataRow[] dataRows)
		{
			return this.Adapter.Update(dataRows);
		}
		[DataObjectMethod(DataObjectMethodType.Insert, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int AddNewTransfer(string TransferID, string FieldName, string HLFieldName, string DefaultValue)
		{
			SqlCommand sqlCommand = this.CommandCollection[1];
			if (TransferID == null)
			{
				sqlCommand.Parameters[0].Value = System.DBNull.Value;
			}
			else
			{
				sqlCommand.Parameters[0].Value = TransferID;
			}
			if (FieldName == null)
			{
				sqlCommand.Parameters[1].Value = System.DBNull.Value;
			}
			else
			{
				sqlCommand.Parameters[1].Value = FieldName;
			}
			if (HLFieldName == null)
			{
				sqlCommand.Parameters[2].Value = System.DBNull.Value;
			}
			else
			{
				sqlCommand.Parameters[2].Value = HLFieldName;
			}
			if (DefaultValue == null)
			{
				sqlCommand.Parameters[3].Value = System.DBNull.Value;
			}
			else
			{
				sqlCommand.Parameters[3].Value = DefaultValue;
			}
			ConnectionState state = sqlCommand.Connection.State;
			if ((sqlCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
			{
				sqlCommand.Connection.Open();
			}
			int result;
			try
			{
				result = sqlCommand.ExecuteNonQuery();
			}
			finally
			{
				if (state == ConnectionState.Closed)
				{
					sqlCommand.Connection.Close();
				}
			}
			return result;
		}
		[DataObjectMethod(DataObjectMethodType.Delete, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int DeleteTransferField(int TransferFieldID)
		{
			SqlCommand sqlCommand = this.CommandCollection[2];
			sqlCommand.Parameters[0].Value = TransferFieldID;
			ConnectionState state = sqlCommand.Connection.State;
			if ((sqlCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
			{
				sqlCommand.Connection.Open();
			}
			int result;
			try
			{
				result = sqlCommand.ExecuteNonQuery();
			}
			finally
			{
				if (state == ConnectionState.Closed)
				{
					sqlCommand.Connection.Close();
				}
			}
			return result;
		}
	}
}
